package com.xuelang.pipeline.app.resource;

import com.xuelang.pipeline.app.resource.impl.NamespaceServiceFallbackImpl;
import com.xuelang.pipeline.app.resource.request.NamespaceListRequest;
import com.xuelang.pipeline.app.resource.request.NamespaceMainRequest;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.resource.dto.NamespaceDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 命名空间服务接口
 *
 * @author xiwen.zxg
 * @since 2024/5/28
 */
@FeignClient(name = "namespace-service", url = "${feign.rpc.workerService}", fallbackFactory = NamespaceServiceFallbackImpl.class)
public interface NamespaceService {

    /**
     * 获取命名空间列表
     *
     * @param namespaceListRequest
     * @return
     */
    @PostMapping(value = "/get/namespace/list", produces = "application/json;charset=utf-8")
    ApiResult<List<NamespaceDTO>> list(@RequestBody @Valid NamespaceListRequest namespaceListRequest);

    /**
     * 创建命名空间
     *
     * @param namespaceMainRequest
     * @return
     */
    @PostMapping(value = "/create/namespace", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> create(@RequestBody @Valid NamespaceMainRequest namespaceMainRequest);

    /**
     * 删除命名空间
     *
     * @param namespaceMainRequest
     * @return
     */
    @PostMapping(value = "/delete", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> delete(@RequestBody @Valid NamespaceMainRequest namespaceMainRequest);
}
